// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

package com.nnee.p_a.p_b;

import java.io.*;
import java.util.Random;
import org.apache.http.Header;
import org.apache.http.entity.AbstractHttpEntity;
import org.apache.http.message.BasicHeader;
import org.apache.http.params.HttpParams;
import org.apache.http.util.EncodingUtils;

// Referenced classes of package com.nnee.a.b:
//            a

public class cls_h extends AbstractHttpEntity
{

    public cls_h(cls_a aa[])
    {
        g = false;
        setContentType("multipart/form-data");
        if(aa == null)
        {
            throw new IllegalArgumentException("parts cannot be null");
        } else
        {
            b = aa;
            f = null;
            return;
        }
    }

    public cls_h(cls_a aa[], HttpParams httpparams)
    {
        g = false;
        if(aa == null)
            throw new IllegalArgumentException("parts cannot be null");
        if(httpparams == null)
        {
            throw new IllegalArgumentException("params cannot be null");
        } else
        {
            b = aa;
            f = httpparams;
            return;
        }
    }

    public static byte[] a()
    {
        Random random = new Random();
        byte abyte0[] = new byte[30 + random.nextInt(11)];
        for(int i = 0; i < abyte0.length; i++)
            abyte0[i] = d[random.nextInt(d.length)];

        return abyte0;
    }

    protected byte[] b()
    {
        if(e == null)
        {
            String s = null;
            if(f != null)
                s = (String)f.getParameter("http.method.multipart.boundary");
            if(s != null)
                e = EncodingUtils.getAsciiBytes(s);
            else
                e = a();
        }
        return e;
    }

    public InputStream getContent()
    {
        if(!isRepeatable() && g)
        {
            throw new IllegalStateException("Content has been consumed");
        } else
        {
            g = true;
            ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
            try {
				com.nnee.p_a.p_b.cls_a.a(bytearrayoutputstream, b, e);
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
            return new ByteArrayInputStream(bytearrayoutputstream.toByteArray());
        }
    }

    public long getContentLength()
    {
        long l1 = com.nnee.p_a.p_b.cls_a.a(b, b());
        long l = l1;
 
        return l;
 
 
    }

    public Header getContentType()
    {
        StringBuffer stringbuffer = new StringBuffer("multipart/form-data");
        stringbuffer.append("; boundary=");
        stringbuffer.append(EncodingUtils.getAsciiString(b()));
        return new BasicHeader("Content-Type", stringbuffer.toString());
    }

    public boolean isRepeatable()
    {
        boolean flag;
        int i;
        flag = false;
        i = ((flag) ? 1 : 0);
while(true)
{
        if(i >= b.length)
            break;
        if(b[i].g()) {i++;} else return flag;
}
flag = true;
        return flag;

    }

    public boolean isStreaming()
    {
        return false;
    }

    public void writeTo(OutputStream outputstream)
    {
        try {
			com.nnee.p_a.p_b.cls_a.a(outputstream, b, b());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    }

    public static final String a = "http.method.multipart.boundary";
    private static final String c = "multipart/form-data";
    private static byte d[] = EncodingUtils.getAsciiBytes("-_1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
    protected cls_a b[];
    private byte e[];
    private HttpParams f;
    private boolean g;

}
